class Info < ActiveRecord::Base
  belongs_to :admin
  belongs_to :infotype
  validates_presence_of :title, :content, :message => "不能为空"
  
  define_index do
    indexes title
    indexes content
    has admin_id, created_at, updated_at
  end
  
  def self.find_less_infos(infotype)
    find(:all, :limit => 10, :order => "updated_at DESC", :conditions => ["infotype_id = ?", infotype])
  end
  
  def self.find_all_infos(infotype)
    find(:all, :order => "updated_at DESC", :conditions => ["infotype_id = ?", infotype])
  end
end
